﻿package net.area80.serverside.errors
{
	import flash.utils.Dictionary;
	import net.area80.serverside.ServerSide;
	
	/**
	* ErrorCode
	* @author Wissarut Pimanmassuriya
	*/
	public class ErrorCodes implements IErrorCodes
	{
		private var errorDict:Dictionary;
		
		public function ErrorCodes ():void {
				errorDict = new Dictionary();
		}
		
		public function addErrorCode (code:String, description:String):void {
				errorDict[code] = description;
		}
		
		public function getErrorMessage (code:String):String {
				if (errorDict[code]) {
					return errorDict[code];
				} else {
					ServerSide.log("Can't find error code \""+code+"\"", ServerSide.DATATYPE_ERROR);
					return code;
				}
		}
		
		public function toString ():String {
			var s:String = "[" + this + " :"
			for (var code:String in errorDict) {
					s += "{" + code +":" + errorDict[code] + "}";
			}
			s += " ]";
			return s;
		}
	}
	
}